#!/bin/sh
set -o nounset
set -o errexit
LOGFILE="/media/Data/Vipre.log"
#cd /root/VipreScanner/
if [ -f 7zip.conf ]
then
rm -v 7zip.conf
fi
mkdir Vipre
wget http://live.sunbeltsoftware.com/Download/ --output-document=Vipre/VIPRERescue.exe
cd Vipre
if [ -a VIPRERescue.exe ]; then
	unzip -o VIPRERescue.exe
	FILE="$RANDOM.exe"
	DIRECTORY="$RANDOM"
	SCANFILE="$RANDOM.exe"
	echo "[Global]" > vpr_dat.ini
	echo "VipreDirectory="$DIRECTORY >> vpr_dat.ini
	echo "VipreProgramName="$FILE >> vpr_dat.ini
	echo "VipreGUIName="$SCANFILE >> vpr_dat.ini
	mv VIPRERescueScanner.exe $FILE
	rm -v VIPRERescue.exe
	rm -v deep_scan.bat
	cp -v ../files/secedit.exe .
	cp -v ../files/subinacl.exe .
	cp -v ../files/VipreScanner.exe ./$SCANFILE
	cp -v ../files/processlist.ini .
	cp -v ../files/7z.exe .
	cp -v ../files/7z.dll .
	cp -v ../files/wget.exe .
	echo ";!@Install@!UTF-8!" > 7zip.conf
	echo 'Title="Vipre Command-Line Virus Scanner"' >> 7zip.conf
	echo 'ExecuteFile="'$SCANFILE'"' >> 7zip.conf
	echo ";!@InstallEnd@!" >> 7zip.conf
	7z a -t7z -mhe=on -m0=lzma -mx=9 -sfx=VIPRERescue.exe *
	cd ..

	cat 7zS.sfx 7zip.conf Vipre/VIPREScanner.7z > VIPRERescue.exe
	echo cat 7zS.sfx 7zip.conf Vipre/VIPREScanner.7z >> $LOGFILE
	#cp -v Vipre/VIPRERescue.exe /media/Data/Tools/Cleaning\ Tools/Malware\ Removal\ Tools/ >> $LOGFILE
	#chmod 777 /media/Data/Tools/Cleaning\ Tools/Malware\ Removal\ Tools/VIPRERescue.exe >> $LOGFILE
	#rm -v VIPRERescue.exe >> $LOGFILE
	rm -v 7zip.conf >> $LOGFILE
	rm -rv Vipre/ >> $LOGFILE
else
	echo "Vipre Rescue Scanner download failed!" >> $LOGFILE
	echo "Please check http://live.sunbeltsoftware.com/Download/" >> $LOGFILE
	rm -rv Vipre/ >> $LOGFILE
fi
